$(function(){
	var bannerInd = 0;
	var bannerInv = null;
	var bannerTime = 5000;
	
	
	changeBanner();
	autoBanner();
	
	var slide = new MySlide({
		imgs : $(".row2 .list"),
		btns : $(".row2 .btns"),
		texts : null,
		wid	:	980,
		ind	:	0,
		autoTime	:	3000,
		inv	:	null,
		ty	:	"ul",
		btnL:	$(".row2 .btnLeft"),
		btnR:	$(".row2 .btnRight"),
		hasNum	:	false,
		path:	"left"
	});
	slide.init();
	
	
	$(".service").css({right:$(".head .nav li:eq(3)").width()+$(".head .nav li:eq(4)").width()});
	
	$(".main .row1 li").mouseover(function(){
		$(".main .row1 li").addClass("otherLi");
		$(this).removeClass("otherLi");
		$(this).find(".line").stop(false,false).animate({width:0,left:0,opacity:"show"},300);
		
	}).mouseleave(function(){
		$(this).find(".line").stop(false,false).animate({width:0,left:200,opacity:"hide"},300);
		$(".main .row1 li").removeClass("otherLi");
	});
	
	$(".main .row3 li").mouseover(function(){
		$(this).find(".line").stop(false,false).animate({width:300,left:0,opacity:"show"},300);
		
	}).mouseleave(function(){
		$(this).find(".line").stop(false,false).animate({width:0,left:100,opacity:"hide"},300);
		
	});
	
	$(".banner .btns li span").mouseover(function(){
		var oLi = $(this).parents("li");
		if(oLi.hasClass("cur")){
			return;
		}
		bannerInd = oLi.index();
		changeBanner();
	});
	
	$(".head .nav li").mouseover(function(){
		$(".subNav").stop(false,false).slideUp().eq($(this).index()).stop(false,false).slideDown();
		
	});
	
	$(".head").mouseleave(function(){
		$(".subNav").stop(false,false).slideUp();
	});
	
	
	
	function changeBanner(){
		$(".banner .imgs div").stop(false,false).fadeOut(700).eq(bannerInd).stop(false,false).fadeIn(700);
		
		var txt = $(".banner .text").eq(bannerInd);
		$(".banner .p1").stop(false,false).animate({top:-50,opacity:"hide"},500);
		$(".banner .p2").stop(false,false).animate({left:-50,opacity:"hide"},500);
		$(".banner .p3").stop(false,false).animate({left:50,opacity:"hide"},500,function(){
			txt.find(".p1").stop(false,false).css({top:-50}).animate({top:0,opacity:"show"},700);
			txt.find(".p2").stop(false,false).css({left:50}).animate({left:0,opacity:"show"},700);
			txt.find(".p3").stop(false,false).css({left:-50}).animate({left:0,opacity:"show"},700);
			autoBanner();
		});
		
		$(".banner .btns li").removeClass("cur")
		.eq(bannerInd).addClass("cur").find(".title");
		
		$(".banner .btns .title").stop(false,false).animate({right:12,opacity:"hide"})
		.eq(bannerInd).stop(false,false).delay(500).animate({right:28,opacity:"show"});
	}
	
	function autoBanner(){
		clearTimeout(bannerInv);
		bannerInv = setTimeout(function(){
			if(bannerInd>=$(".banner .imgs div").size()-1){
				bannerInd = 0;
			}else{
				bannerInd++;
			}
			changeBanner();
		},bannerTime);
	}
	
	
});
